package com.lxl.hadoop.reverse;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @Author lixilin
 * @Date 2022/1/9 12:20
 * @Description
 */
public class WcReduce1 extends Reducer<Text, NullWritable,Text, NullWritable> {
    Text outKey = new Text();
    NullWritable outVal = NullWritable.get();

    @Override
    protected void reduce(Text key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
        // at--a.txt
        int sum =0;
        for (NullWritable value : values) {
            sum+=1;
        }
        String out = key.toString()+"\t"+sum;
        outKey.set(out);
        context.write(outKey,outVal);

    }
}
